import 'package:flutter/material.dart';
import 'package:flutter_app/counter/counter_demo.dart';
import 'package:flutter_app/utils/log_util.dart';

import 'page_test.dart';

///author: create by SunJH
///时间: 2022/1/4 0004
///邮箱: 965989158@qq.com
///描述: 返回按钮的测试
///
class BackTest extends StatelessWidget {
  const BackTest({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    GlobalKey<NavigatorState> _key = GlobalKey();
    return Scaffold(
      body: WillPopScope(
          onWillPop: ()async{
            if(_key.currentState!.canPop()){
              LogUtil.logI("可以退出");
              _key.currentState!.pop();
              return false;
            }
              LogUtil.logI("不能退出");
              return true;
          },
          child:Navigator(
            key: _key,
            onGenerateRoute: (settings)=>MaterialPageRoute(builder: (context){
              return const Counter();
            }),
          )),
    );
  }
}
